# -*- coding:utf-8 -*-

import requests
from lxml import etree
from fake_useragent import UserAgent
from http import cookiejar
import json
from datetime import datetime

requests.packages.urllib3.disable_warnings()  # 忽略HTTPS安全警告

# 根据京东URL商品详细页面，提取评价信息
class Test_Get():
    def __init__(self):
        #声明一个CookieJar对象实例来保存cookie
        self.cookie = cookiejar.CookieJar()
        ua = UserAgent(use_cache_server=False)  # 禁用服务器缓存
        self.headers = {
            "User-Agent": "kwai-android",
            "Content-Type": "application/x-www-form-urlencoded"
        }


    def get_contents(self):
        postData = {
            "pageNum": "1",
            "numPerPage": "20",
            "title":"",
            "buyer_name":"",
            "agent_name":"",
            "proj_code":"",
            "bid_type": "108",
            "type":"",
            "dist_code": "340001",
            "pubDateStart":"",
            "pubDateEnd":"",
            "pProviceCode": "340000",
            "areacode_city": "340001",
            "areacode_dist":"",
            "channelCode": "sjcg_zbgg",
            "three":""

        }
        # url = "https://www.propertyguru.com.sg/property-for-sale?market=residential&property_type_code%5B%5D=CONDO&property_type_code%5B%5D=APT&property_type_code%5B%5D=WALK&property_type_code%5B%5D=CLUS&property_type_code%5B%5D=EXCON&property_type=N&freetext=Farrer+Park&newProject=all"
        url = "https://api.meituan.com/meishi/filterapi/select/selectlist?cn_pt=RN&stationId=0&offset=0&rn_bundle_version=rn_meishi_snack_1.11.0&tagContent=&tagType=&mypos=41.120617709771366%2C122.96264564263679&sort=defaults&limit=2&cityId=10&cateId=36&__vhost=api.meishi.meituan.com&utm_source=baidumobile&utm_medium=android&utm_term=1000050202&version_name=10.5.202&utm_content=869139022485730&utm_campaign=AgroupBgroupC0E0Ghomepage_category1_1__a1__c-1024__e64351__gfood&ci=10&msid=8691390224857301574517893620&uuid=0000000000000C05B557AB532497890B66040A90098150000000000000449446&userid=-1&__reqTraceID=1ad94dac-2d8d-4b75-a61b-a61ffe7da5f1&__skck=8f5973b085446090f224af74e30e0181&__skts=1574518620&__skua=fdf056c6020e036ad5f487701be54b81&__skno=f68b447b-2d55-4021-8b8a-4fd56a9103f9&__skcy=Mp3AhwJhJVPv0MTYyXpm4aC4n%2F4%3D "
        html = HttpUtils.do_request("GET", url, self.headers, postData)
        selector = etree.HTML(html.text)
        xpath = selector.xpath('//div[@class="col-xs-12 col-sm-7 listing-description"]')
        for i in xpath:
            aa = i.xpath('./div/div/p//text()')
            bb = i.xpath('./ul[@class="listing-features"]/li//text()')
            cc = i.xpath('./ul[@class="listing-features pull-left"]/li//text()')
            pass


if __name__ == '__main__':
    test_get = Test_Get()
    test_get.get_contents()